<link rel="stylesheet" href="../static/css/jquery.fileupload.css">

<script src="../static/js/jquery-3.3.1.min.js" type="text/javascript" ></script>
<script src="../static/js/jquery.ui.widget.js" type="text/javascript" ></script>
<script src="../static/js/jquery.iframe-transport.js" type="text/javascript" ></script>
<script src="../static/js/jquery.fileupload.js" type="text/javascript" ></script>


<span class="btn btn-success fileinput-button" id="fileUploadContainer">click here to upload excel file
<input id="fileupload" type="file" name="fileupload"  ></span>
<script>
    var myFLag = 0
    $(document).ready(function(){
        var url = "../app/excelencrypt"

        $('#fileupload').fileupload({
            url: url,
            dataType: 'json',
            start:function() {
                totalSuccessFile = 0

            },
            stop:function() {

            },
            add: function (e, data) {
                console.log(data.originalFiles[0].name+" "+(myFLag++))
                var flag = true
                for (var j=0;j<data.originalFiles.length;j++) {
                    var filename = data.originalFiles[j].name;
                    //console.log(filename+" "+(myFLag++))

                    //if(filename.indexOf(".xls")==-1 && flag==true){
                    //    flag = false
                     //   break
                    //}
                }

                if (flag) {

                    data.submit();
                } else {

                }

                if (myFLag==data.originalFiles.length) {
                    myFLag = 0
                    if (flag==false) {
                        alert("请上传excel格式的文件");
                    }
                }



            },
            done: function (e, data) {
                $.each(data.result.files, function (index, file) {
                    //$('<p/>').text(file.name).appendTo('#files');
                });



            },
            progressall: function (e, data) {
                console.log(data)
                var progress = parseInt(data.loaded / data.total * 100, 10);


                if (progress==100) {

                }
            }
        }).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled');
    });
</script>